home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / lib / linuxdoc-sgml / bin / qtex < prev    next >
Text File  |  1994-06-23  |  4KB  |  203 lines

  1. #! /bin/sh
  2. ######################################################################
  3. #
  4. # Authors:        Alexander Horz and Tom Gordon
  5. # Date:           11-28-89
  6. # Last Modified:  22 May 92
  7. #
  8. ######################################################################
  9.  
  10. # Set to path of linuxdoc-sgml directory
  11. LINUXDOC=/usr/skunk/lib/linuxdoc-sgml
  12.  
  13. # Set to command to use for LaTeX
  14. LATEX="latex"
  15.  
  16. # Set to command to use for dvips. 
  17. DVI2PS="dvips"
  18.  
  19. # You shouldn't have to edit anything below this line.
  20.  
  21. TEXINPUTS=":$LINUXDOC/lib"
  22. export TEXINPUTS
  23.  
  24.  
  25. ######################################################################
  26. ## all switches are "no" by default
  27. ######################################################################
  28.  
  29. DVI="no"
  30. TWO_PASSES="yes"
  31. SAVE="no"
  32. BIBTEX="no"
  33. CHAPTER="no"
  34. VERBOSE="no"
  35.  
  36. ######################################################################
  37. ## 
  38. ######################################################################
  39.  
  40. FILE=" "
  41. SUFFIXES="log blg aux toc lof lot log dlog bbl"
  42. PROGNAME=$0
  43.  
  44. ######################################################################
  45. # synopsis: announce <string>
  46. #
  47. #          echo string on std_err if verbose mode is set on
  48. ######################################################################
  49.  
  50. announce () {   
  51.     if [ $VERBOSE = "yes" ]
  52.     then
  53.         echo  $1 >&2
  54.     fi
  55. }
  56.  
  57. ######################################################################
  58. # synopsis: cleanup
  59. #
  60. # remove all the files $FILE.$SFX, where $SFX is in $SUFFIXES
  61. ######################################################################
  62.  
  63. cleanup () {
  64.     if [ $SAVE = "no" ] 
  65.     then
  66.         announce "removing temporary files "
  67.         for SFX in  $SUFFIXES
  68.         do
  69.             if [ -f $FILE.$SFX ]
  70.             then
  71.                 /bin/rm $FILE.$SFX
  72.             fi
  73.         done
  74.     fi
  75.     if [ -f /tmp/$$.tex ]
  76.     then
  77.         mv /tmp/$$.tex $FILE.tex
  78.     fi
  79. }
  80.  
  81. ######################################################################
  82. # synopsis: usage
  83. #
  84. # print a short help message
  85. ######################################################################
  86.  
  87. usage () {
  88. echo "    qtex     [-d]        * dvi instead of PostScript";
  89. echo "        [-s]        * save all temporary files";
  90. echo "        [-x]        * cross references";
  91. echo "        [-g]        * german";
  92. echo "        [-b]        * bibliography";
  93. echo "        [-v]        * verbose";
  94. echo "        [-c]        * single chapter";
  95. echo "        <filename>    * .tex extension MUST be ommitted (BUG)";
  96. exit 1 
  97. }
  98.  
  99. ######################################################################
  100. # synopsis: LaTeX  $FILE
  101. #
  102. # run LaTeX on $FILE 
  103. ######################################################################
  104.  
  105.  
  106. LaTeX () {   
  107.     $LATEX $1 > /dev/null
  108.     if [ $? != 0 ]    # some TeX error
  109.     then
  110.         echo $PROGNAME: LaTeX error. See $1.log  >&2
  111.         mv $1.log /tmp/x$$.log
  112.         cleanup
  113.         mv /tmp/x$$.log $1.log
  114.         exit 1
  115.     fi
  116. }
  117.  
  118. ######################################################################
  119. ##         command line argument processing ...
  120. ######################################################################
  121.  
  122. case "$1" in
  123.     "help" | "HELP" | "Help" | "-help" ) usage
  124. esac
  125.  
  126. trap 'cleanup; exit 1' 1 2 3 9
  127.  
  128. set -- `getopt dxgbsvc $*`
  129.  
  130. if [ $? != 0 ]
  131. then
  132.     usage
  133. fi
  134.  
  135. for i in $*
  136. do
  137.         case $i in
  138.           -c)       CHAPTER="yes"; shift;;
  139.           -d)    DVI="yes"; shift;;
  140.           -x)      TWO_PASSES="yes"; shift;;
  141.           -b)      BIBTEX="yes"; shift;;
  142.           -s)        SAVE="yes"; shift;;
  143.           -v)    VERBOSE="yes"; shift;;
  144.               --)       shift;
  145.             break;;
  146.         esac
  147. done
  148.  
  149. if [ "$1" = "" ] 
  150. then
  151.     cat > $$.tex  # write standard input to file
  152.     FILE=$$
  153.     SUFFIXES=$SUFFIXES" tex"
  154. else
  155.     FILE=$1
  156. fi
  157.  
  158.  
  159. if [ $CHAPTER = "yes" ]
  160. then
  161.     announce "creating report from a chapter ..."
  162.     mv $FILE.tex /tmp/$$.tex
  163.     awk -f $LINUXDOC/lib/chapt.awk /tmp/$$.tex > $FILE.tex
  164. fi
  165.  
  166. ######################################################################
  167.  
  168. announce "producing $FILE.dvi ..."
  169.  
  170. LaTeX $FILE
  171.  
  172. if [ $BIBTEX = "yes" ]
  173. then
  174.     TWO_PASSES="yes"
  175.     announce "BiBTeXing $FILE ... "
  176.     bibtex $FILE > /dev/null
  177.     
  178.     announce "LaTeXing again ... "
  179.     LaTeX $FILE  
  180. fi
  181.  
  182. if [ $TWO_PASSES = "yes" ]
  183. then
  184.     announce "LaTeXing again ... "
  185.         LaTeX $FILE
  186. fi
  187.  
  188. if [ $DVI = "no" ]
  189. then 
  190.     SUFFIXES="$SUFFIXES dvi"
  191.     announce "translating $FILE.dvi to PostScript ... "
  192.     $DVI2PS $FILE.dvi  2> /dev/null
  193. else
  194.     cat $FILE.dvi 
  195.     rm -f $FILE.dvi
  196. fi
  197.  
  198. cleanup
  199.  
  200. # end of qtex script 
  201.  
  202.  
  203.